/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2024.
 * Description: support gpio lock
 * Author: lisongze <lisongze2@huawei.com>
 * Create: 2024-07-30
 */

#ifndef _RTOS_GPIO_SPIN_LOCK_H
#define _RTOS_GPIO_SPIN_LOCK_H

#ifdef CONFIG_RTOS_GPIO_LOCK

#include <linux/hal/gpio_lock.h>

/*
 * It is agreed a constraint to avoid deadlock.
 * rtos_gpio_spin_lock must be added before the GPIO drive lock,
 * rtos_gpio_spin_unlock must be added after the GPIO drive unlock.
 */
static inline void rtos_gpio_spin_lock(void)
{
	rtos_gpio_lock();
}
static inline void rtos_gpio_spin_unlock(void)
{
	rtos_gpio_unlock();
}

#else
static inline void rtos_gpio_spin_lock(void) {}
static inline void rtos_gpio_spin_unlock(void) {}

#endif
#endif
